package com.ruoyi.his.controller;

import java.util.List;
import java.util.Map;

import com.ruoyi.his.domain.HisPatient;
import com.ruoyi.his.domain.HisRegister;
import com.ruoyi.his.service.IHisPatientService;
import com.ruoyi.his.service.IHisRegisterService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.his.domain.HisDepartment;
import com.ruoyi.his.service.IHisDepartmentService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;

/**
 * 挂号收费Controller
 * 
 * @author ruoyi
 * @date 2021-11-04
 */
@RestController
@RequestMapping("/his/department")
public class HisDepartmentController extends BaseController
{
    @Autowired
    private IHisDepartmentService hisDepartmentService;

    @Autowired
    private IHisPatientService hisPatientService;


    @Autowired
    private IHisRegisterService IHisRegisterService;



    /**
     * 查询挂号收费列表
     */
    @PreAuthorize("@ss.hasPermi('his:department:list')")
    @GetMapping("/list")
    public TableDataInfo list(HisDepartment hisDepartment)
    {
        startPage();
        List<HisDepartment> list = hisDepartmentService.selectHisDepartmentList(hisDepartment);
        return getDataTable(list);
    }



    @GetMapping(value = "/selectDoctorByDepartment/{id}")
    public TableDataInfo selectDoctorByDepartment(@PathVariable String id)
    {
        startPage();
        List<Map<String, Object>> list = hisDepartmentService.selectDoctorByDepartment(id);
        return getDataTable(list);

    }

    /**
     * 1.-- 根据病人就诊卡查询病人信息
     *
     *
     */
    @PostMapping("/gh")
    public AjaxResult gh(@RequestBody Map data){
        String registered = hisDepartmentService.registered(data);
        return AjaxResult.success(registered);
    }







    /**
     * 导出挂号收费列表
     */
    @PreAuthorize("@ss.hasPermi('his:department:export')")
    @Log(title = "挂号收费", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HisDepartment hisDepartment)
    {
        List<HisDepartment> list = hisDepartmentService.selectHisDepartmentList(hisDepartment);
        ExcelUtil<HisDepartment> util = new ExcelUtil<HisDepartment>(HisDepartment.class);
        return util.exportExcel(list, "挂号收费数据");
    }

    /**
     * 获取挂号收费详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:department:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(hisDepartmentService.selectHisDepartmentById(id));
    }

    /**
     * 新增挂号收费
     */
    @PreAuthorize("@ss.hasPermi('his:department:add')")
    @Log(title = "挂号收费", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HisDepartment hisDepartment)
    {
        return toAjax(hisDepartmentService.insertHisDepartment(hisDepartment));
    }

    /**
     * 修改挂号收费
     */
    @PreAuthorize("@ss.hasPermi('his:department:edit')")
    @Log(title = "挂号收费", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HisDepartment hisDepartment)
    {
        return toAjax(hisDepartmentService.updateHisDepartment(hisDepartment));
    }

    /**
     * 删除挂号收费
     */
    @PreAuthorize("@ss.hasPermi('his:department:remove')")
    @Log(title = "挂号收费", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(hisDepartmentService.deleteHisDepartmentByIds(ids));
    }
}
